package com.wanyang.util;

import org.apache.log4j.Logger;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by Alan on 15/8/11.
 */
public class SimpleDateFormatFactory {
    private static Logger logger = Logger.getLogger(SimpleDateFormatFactory.class);

    public static SimpleDateFormat getDateFormat(String pattern) {
        return new SimpleDateFormat(pattern);
    }

    public static Date toDate(String dateStr, String pattern) {
        try {
            return getDateFormat(pattern).parse(dateStr);
        } catch (ParseException e) {
            logger.error(AssUtils.parse(e));
        }
        return null;
    }

    public static SimpleDateFormat getInstance(String pattern) {
        return getDateFormat(pattern);
    }

}